package Thread;
//创建MyThread子类，继承Thread，并重写Thread中的run方法
 class MyThread extends Thread{
    //重写父类Thread中的run方法

    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println("hello run");
        }
    }public class Demo1{
        public static void main(String[] args) throws InterruptedException {
            Thread t=new MyThread();//发生了向上转型
            t.start();//启动线程
            Thread.sleep(1000);
            for (int i = 0; i < 5; i++) {
                System.out.println("hello main");
            }
        }
    }

}
